package com.efruit.subsystemadapters;

import com.efruit.authority.AuthorityFacade;
import com.efruit.authority.IUserInfo;
import com.efruit.externalInterfaces.IAuthority;
import com.efruit.to.AuthorityTO;

public class AuthorityAdapter implements IAuthority {
	private AuthorityFacade authorityFacade;

	public AuthorityAdapter() {
		System.out.println("adapter");
		authorityFacade = new AuthorityFacade();
	}

	@Override
	public AuthorityTO login(String username, String password) {
		System.out.println("begin login");
		IUserInfo userinfo = authorityFacade.login(username, password);
		if (userinfo == null){
			System.out.println("info null");
			return null;
		}
		System.out.println("return new authorityto");
		return new AuthorityTO(userinfo.getUserId(), userinfo.getUsername(),userinfo.getAuthority());
	}

}
